package com.demo.http.androidnative;

import com.demo.http.HttpCallback;
import com.demo.http.androidnative.bean.RequestInfo;

import java.util.Map;

import static com.demo.http.androidnative.bean.RequestInfo.Type.GET;
import static com.demo.http.androidnative.bean.RequestInfo.Type.POST;

/**
 * Created by se1 on 16-11-16.
 */
public class HttpUtil {

    private HttpUtil() {
    }

    private static class SingletonHolder {
        private final static HttpUtil INSTANCE = new HttpUtil();
    }

    public static HttpUtil getInstance() {
        return SingletonHolder.INSTANCE;
    }

    public void get(String host, Map<String, String> params, HttpCallback callback) {
        new HttpTask(callback).execute(new RequestInfo(GET, host, params));
    }

    public void post(String host, Map<String, String> params, HttpCallback callback) {
        new HttpTask(callback).execute(new RequestInfo(POST, host, params));
    }
}
